package fr.Tag;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

public class TableGenerator extends TagSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = -6310801630442198148L;
	

	private int columnNbr;

	@Override
	public int doStartTag() throws JspException {
		
		try {
			//Get the writer object for output.
			JspWriter out = pageContext.getOut();

			//Perform substr operation on string.
			out.println("<table style=\"border:1px solid\">");
			out.println("<tr>");
			for (int i = 0; i < columnNbr; i++) {
				out.println("<td>");
				out.println("hello");
				out.println("</td>");
			}
			
			out.println("</tr>");		
			out.println("</table>");

		} catch (IOException e) {
			e.printStackTrace();
		}
		return SKIP_BODY;
	}

	/**
	 * @return the columnNbr
	 */
	public int getColumnNbr() {
		return columnNbr;
	}

	/**
	 * @param columnNbr the columnNbr to set
	 */
	public void setColumnNbr(int columnNbr) {
		this.columnNbr = columnNbr;
	}
	
	
	
}